<template>
    <el-container class="home-container">
        <el-container>
            <el-aside width="200px">
                <div class="logo">
                    <img src="../assets/LogoWhite.png"/>
                </div>
                <menu-bar :menuData="menuData"></menu-bar>
            </el-aside>
            <el-main>
                <el-header height="80px">
                    <header-bar></header-bar>
                </el-header>
                <div class="main-content">
                    <!-- <breadcrumb/> -->
                    <transition name="fade-transform" mode="out-in">
                        <router-view />
                    </transition>
                </div>
            </el-main>
        </el-container>
    </el-container>
</template>
<script>
import headerBar from '@/components/headerBar.vue'
import menuBar from '@/components/menuBar.vue'
import breadcrumb from '@/components/breadcrumb.vue'
// import { decode } from '@/assets/js/utils/Base64'
export default{
    components: {
        headerBar,
        menuBar,
        breadcrumb
    },
    data() {
        return {
            activePath: '',
            menuData: [
                // {
                //     name:"首页",
                //     id: 'home',
                //     icon: 'el-icon-house',
                //     path: '/home',
                //     permission: 'indexPage',
                // },
                {
                    name:"实验项目名称",
                    id: 'scholl',
                    icon: 'el-icon-school',
                    path: '/researchProjects',
                    permission: 'allSchoolManager',
                    // menuAuthority,
                    children:[
                        {
                            name: '科研项目',
                            id: 'scholl-1',
                            path: '/researchProjects',
                            permission: 'allResearchProjects',
                            // menuAuthority
                        },
                        {
                            name: '教学课程',
                            id: 'scholl-2',
                            path: '/teachingCourses',
                            permission: 'allTeachCourse',
                            // menuAuthority
                        },
                        {
                            name: '学位论文和创新实践',
                            id: 'scholl-3',
                            path: '/innovativePractice',
                            permission: 'allPaperPractice',
                            // menuAuthority
                        },
                        // {
                        //     name: 'PRP项目',
                        //     id: 'scholl-4',
                        //     path: '/schollPrpProject',
                        //     permission: 'allPRPprojects',
                        // },
                        // {
                        //     name: '大学生创新创业训练计划',
                        //     id: 'scholl-5',
                        //     path: '/schollTrainingPlan',
                        //     permission: 'allBuildTrain',
                        // }
                    ]
                },
                {
                    name:"部门业务",
                    id: 'depart',
                    icon: 'el-icon-collection',
                    path: '/scientific',
                    permission: 'departmentManager',
                    // menuAuthority,
                    children:[
                        {
                            name: '科研项目',
                            id: 'depart-1',
                            path: '/scientific',
                            permission: 'depResearchProjects',
                            // menuAuthority
                        },
                        {
                            name: '教学课程',
                            id: 'depart-2',
                            path: '/teaching',
                            permission: 'depTeachCourse',
                            // menuAuthority
                        },
                        {
                            name: '学位论文和创新实践',
                            id: 'depart-3',
                            path: '/degree',
                            permission: 'depPaperPractice',
                        },
                        // {
                        //     name: 'PRP项目',
                        //     id: 'depart-4',
                        //     path: '/depPrpProject',
                        //     permission: 'depPRPprojects',
                        // },
                        // {
                        //     name: '大学生创新创业训练计划',
                        //     id: 'depart-5',
                        //     path: '/depTrainingPlan',
                        //     permission: 'depBuildTrain',
                        // }
                    ]
                },
                {
                    name: "配置管理",
                    id: 'allocation',
                    icon: 'el-icon-setting',
                    path: '/dangerType',
                    permission: 'configManager',
                    // menuAuthority,
                    children: [{
                        name: "危险源类型",
                        id: 'allocation-1',
                        path: '/dangerType',
                        permission: 'riskSrcType',
                        // menuAuthority
                    },{
                        name: "危险源名称",
                        id: 'allocation-2',
                        path: '/dangerName',
                        permission: 'riskSrcName',
                        // menuAuthority
                    },{
                        name: "个人防护",
                        id: 'allocation-3',
                        path: '/protect',
                        permission: 'labProtect',
                        // menuAuthority
                    },{
                        name: "安全用具",
                        id: 'allocation-4',
                        path: '/safetyEquipment',
                        permission: 'labSafetyTools',
                        // menuAuthority
                    },{
                        name: "事故类型",
                        id: 'allocation-5',
                        path: '/accidentType',
                        permission: 'labAccidentType',
                        // menuAuthority
                    },{
                        name: "废弃物类型",
                        id: 'allocation-6',
                        path: '/wasteType',
                        permission: 'labTrashType',
                        // menuAuthority
                    }]
                },{
                    name: "数据统计",
                    id: 'statistics',
                    icon: 'el-icon-document',
                    path: '/statisticsCompany',
                    permission: 'statisticsManager',
                    children: [{
                        name: "学院项目统计",
                        id: 'statistics-1',
                        path: '/statisticsCompany',
                        permission: 'statisticsCompany',
                    },{
                        name: "项目类型统计",
                        id: 'statistics-2',
                        path: '/statisticsProjects',
                        permission: 'statisticsProjects',
                    }]
                },
                {
                    name: "系统管理",
                    id: 'system',
                    icon: 'el-icon-document',
                    path: '/department',
                    permission: 'systemManager',
                    // menuAuthority,
                    children: [{
                        name: "部门查询",
                        id: 'system-1',
                        path: '/department',
                        permission: 'companyManger',
                        // menuAuthority
                    },{
                        name: "用户查询",
                        id: 'system-2',
                        path: '/userList',
                        permission: 'userManager',
                        // menuAuthority
                    },{
                        name: "权限设置",
                        id: 'system-3',
                        path: '/permissionsSet',
                        permission: 'roleFunctionSet',
                        // menuAuthority
                    },{
                        name: "用户权限",
                        id: 'system-4',
                        path: '/userPermissions',
                        permission: 'userRoleSet',
                        // menuAuthority
                    },{
                        name: "日志查询",
                        id: 'system-5',
                        path: '/logList',
                        permission: 'logManager',
                        // menuAuthority
                    }]
                }
            ]
        }
    },
    created() {
        // let rightCodes = JSON.parse(localStorage.getItem('rightCodes'))
        // let arr = JSON.parse(JSON.stringify(this.menuData))
        // this.getMenu(arr,rightCodes)
    },
    watch: {
        
    },
    // beforeRouteEnter: (to, from, next) => {
    //     const token = sessionStorage.getItem('token')
    //     const rightCodes = sessionStorage.getItem('rightCodes')
    //     if(to.path == '/login') {
    //         next()
    //     } else {
    //         if(!token) {
    //             next('/login')
    //         } else {
    //             if(rightCodes.length > 0) {
    //                 next()
    //             } else {
    //                 next('/noPage')
    //             }
    //         }
    //     }
    //     if(token && to.path == '/') {
    //         next('/')
    //     }
    // },
    methods: {
        // getMenu(arr,rightCodes) {
        //     arr = arr.filter(item => {
        //         return item.permission && rightCodes.indexOf(item.permission) !== -1
        //     })
        //     arr.forEach(item =>{
        //         if(item.children){
        //             item.children = this.getMenu(item.children,rightCodes)
        //         }
        //     })
        // }
    }
}
</script>
<style lang="less" scoped>
.home-container {
    position: relative;
    height: 100%;
    width: 100%;
    .el-header{
        position: fixed;
        top: 0;
        width: 100%;
        height: 80px;
        box-shadow: 1px 1px 3px #b1d1ee;
        background: #fff;
        box-sizing: border-box;
        z-index: 100;
    }
    .el-aside{
        background: #106fc6;
    }
    .el-main{
        padding: 0;
        background: #f2f2f2;
    }
    .main-content{
        margin-top: 80px;
        padding: 20px;
    }
    .logo{
        padding: 10px 0;
        text-align: center;
        img {
            width: 180px;
        }
        span {
            color: #fff;
            font-size: 18px;
            font-weight: 600;
            padding-left: 10px;
        }
    }
}
.el-aside::-webkit-scrollbar {
    display: none;
}
.el-aside::-o-scrollbar {
    display: none;
}
</style>